package net.ryian.sms.service.impl;

import com.alibaba.fastjson.JSONObject;
/**
 * Created by allenwc on 16/9/20.
 */
public class DayuSmsService extends BaseSmsService {


    private String url;
    private String appkey;
    private String secret;
    private String signature;

    public DayuSmsService() {
        super();
        url = prop.getProperty("dayusms.url");
        appkey = prop.getProperty("dayusms.appkey");
        secret = prop.getProperty("dayusms.secret");
        signature = prop.getProperty("dayusms.signature");
    }

    public void setSignature(String signaturePropertyName) {
        this.signature = prop.getProperty(signaturePropertyName);
    }

    @Override
    public void send(String mobile, String msg) throws Exception {
        throw new Exception("unsupported method!");
    }

    @Override
    public void send(String mobile, String template, String... values) throws Exception {
//        TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
//        AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
//        req.setSmsType("normal");
//        req.setSmsFreeSignName(signature);
//        if(values != null && values.length>0) {
//            JSONObject obj = new JSONObject();
//            for(int i=0;i<values.length;i++) {
//                obj.put("p"+String.valueOf(i+1),values[i]);
//            }
//            req.setSmsParamString(obj.toJSONString());
//        }
//        req.setRecNum(mobile);
//        req.setSmsTemplateCode(prop.getProperty(template));
//        AlibabaAliqinFcSmsNumSendResponse rsp = client.execute(req);
//        logger.info(rsp.getBody());
    }

	@Override
	public void send(String mobile, String templatecode, String signature, String... values) throws Exception {
		// TODO Auto-generated method stub
//		TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
//        AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
//        req.setSmsType("normal");
//        req.setSmsFreeSignName(signature);
//        if(values != null && values.length>0) {
//            JSONObject obj = new JSONObject();
//            for(int i=0;i<values.length;i++) {
//                obj.put("p"+String.valueOf(i+1),values[i]);
//            }
//            req.setSmsParamString(obj.toJSONString());
//        }
//        req.setRecNum(mobile);
//        req.setSmsTemplateCode(templatecode);
//        AlibabaAliqinFcSmsNumSendResponse rsp = client.execute(req);
//        logger.info(rsp.getBody());
	}

}
